﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using RuleCode.Table;

namespace map.member
{
    public partial class editcell : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Label_id.Visible = false;
            TextBox_id.Visible = false;
            DropDownList_id.Visible = false;
            if (RadioButtonList1.Text == "商品分类"
                || RadioButtonList1.Text == "商品内容"
                || RadioButtonList1.Text == "论坛分类"
                || RadioButtonList1.Text == "论坛内容"
                )
            {
                Label_id.Visible = true;
                TextBox_id.Visible = true;
                DropDownList_id.Visible = true;
                Label_id.Text =RadioButtonList1.Text+ "编码:";
            }
            if (   RadioButtonList1.Text == "链接"
                )
            {
                Label_id.Visible = true;
                TextBox_id.Visible = true;
                DropDownList_id.Visible = false;
                Label_id.Text = "外部链接地址:";
            }
            TextBox_word.Text = RadioButtonList1.Text;

        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            string ScriptTag =
            "<script type=\"text/javascript\">parent.cancelcell();</script>";
            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(),
                    "messagew1", ScriptTag, false);
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string linkhtml = "";
            linkhtml += " <a type=\"" + RadioButtonList1.SelectedIndex.ToString() + "\" href=\"";
            if (RadioButtonList1.SelectedIndex < 14)
            {
                cbuser u = cbuser.Find(" cbuserid = '" + AliApi.appUserId + "'");
                //linkhtml +=ResolveUrl( "~/member/default.aspx")+"?cbshoppageid=" + RadioButtonList1.SelectedIndex.ToString()
                linkhtml +=  "../member/default.aspx" +"?cbshoppageid=" + RadioButtonList1.SelectedIndex.ToString()
                    + "&id=" + u.RECID.ToString()
                    + "&value=" + TextBox_id.Text 
                    + "&orderby=" + DropDownList_id.SelectedIndex.ToString();
            }
            else
            {
                linkhtml += TextBox_id.Text;
            }
            linkhtml += "\"  ";
            if (CheckBox_newpage.Checked)
            {
                linkhtml += " target=\"_blank\" ";
            }
            else
            {
                linkhtml += " target=\"_parent\" ";
            }

            linkhtml+= ">"+TextBox_word.Text+"</a>";

            string ScriptTag =
                        "<script type=\"text/javascript\">parent.confirmcell('"
                        + linkhtml + "');</script>";
            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(),
                    "messagew", ScriptTag, false);
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            string ScriptTag =
                        "<script type=\"text/javascript\">parent.confirmcell('"
                        + "" + "');</script>";
            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(),
                    "messagew", ScriptTag, false);
        }
    }
}
